package huawei;

import java.util.*;
import java.util.stream.Collectors;

/**
 * 斗地主之顺子
 */
public class Sunzi {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);

        List<String> list = Arrays.stream(scanner.nextLine().split(" ")).collect(Collectors.toList());

        Sunzi sunzi = new Sunzi();
        sunzi.solution(list);

    }

    public void solution(List<String> list) {
        List<Integer> orgPai = new ArrayList<>();
        for (String s : list) {
            if (!"2".equals(s)) {
                int num = getNum(s);
                orgPai.add(num);
            }
        }

        // 从大到小排序
        orgPai.sort(Integer::compareTo);


        List<List<Integer>> hold = new ArrayList<>();

        Set<Integer> used = new HashSet<>();

        for (int i = 0; i < orgPai.size() - 5; i++) {
            if (used.contains(i)) {continue;}

            ArrayList<Integer> every = new ArrayList<>();
            every.add(i);

            for (int j = i + 1; j < orgPai.size(); j++) {
                if (used.contains(j) || orgPai.get(j).equals(orgPai.get(every.get(every.size() - 1)))) continue;
                if (orgPai.get(j).equals(orgPai.get(every.get(every.size() - 1)) + 1)) {
                    every.add(j);
                } else {
                    i = j;
                    break;
                }
            }

            if (every.size() >= 5) {
                hold.add(every);
                used.addAll(every);
            }
        }

        if (hold.isEmpty()) {
            System.out.println("No");
        } else {
            for (int i = 0; i < hold.size(); i++) {
                for (int j = 0; j < hold.get(i).size(); j++) {
                    Integer i1 = hold.get(i).get(j);
                    System.out.print(getCharacter(orgPai.get(i1)) + " ");
                }
                System.out.println();
            }
        }


    }

    public int getNum (String c) {
        if ("J".equals(c)) {
            return 11;
        } else if ("Q".equals(c)) {
            return 12;
        } else if ("K".equals(c)) {
            return 13;
        } else if ("A".equals(c)) {
            return 14;
        } else {
            return Integer.parseInt(c);
        }
    }

    public String getCharacter(int num) {
        if (11 == num) {
            return "J";
        } else if (12 == num) {
            return "Q";
        } else if (13 == num) {
            return "K";
        } else if (14 == num) {
            return "A";
        } else {
            return num + "";
        }
    }
}
